package com.xuecheng.order.task;

import cn.hutool.core.date.DateUtil;
import com.xuecheng.order.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class PaymentJob {

    @Autowired
    OrdersService ordersService;

    //每隔30秒，查询15分钟之前的订单，处理超时订单
    @Scheduled(cron = "0/30 * * * * ?")
    public void handle () {
        System.out.println("当前时间：" + DateUtil.now());
        try {
            ordersService.getPayment();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
